for the bottom of the right;* @param string $QZ The file name of the image after the watermark is prefixed with the original file name* @return Mixed is the name of the image after the watermark is generated, the failure returns false*/function WaterMark ($groundName, $waterName, $waterPos =0, $QZ = "Wa_") {/* Gets the watermark picture is the current path, or the path is specified */$curpath = RTrim ($this->path, "/"). " /";$dir = DirName ($waterName);if ($dir = = ".") {$wpath = $curpath;}else
;
$savepath = $savepath? $savepath: $path;
$savefile = $savepath. ' /'. $savename;
$srcinfo = @getimagesize ($SRCIMG);
if (! $srcinfo) {
return-1; The original file does not exist
}
$waterinfo = @getimagesize ($WATERIMG);
if (! $waterinfo) {
Return-2; Watermark picture does not exist
}
$SRCIMGOBJ = Image_create_from_ext ($SRCIMG);
if (! $srcImgObj) {
return-3; The original file image object failed to build
= $savepath./. $savename;
$srcinfo = @getimagesize ($SRCIMG);
if (! $srcinfo) {
return-1; The original file does not exist
}
$waterinfo = @getimagesize ($WATERIMG);
if (! $waterinfo) {
Return-2; Watermark picture does not exist
}
$SRCIMGOBJ = Image_create_from_ext ($SRCIMG);
if (! $srcImgObj) {
return-3; The original file image object failed to build
}
$WATERIMGOBJ = Image_create_from_ext ($WATERIMG);
if (
maintenance. Here is the key to give the following function name, that is, the realization of the watermark function is mainly by these functions function operation1.imagecreatefromjpeg//Open JPG image 2.imagecreatefromgif//open GIF picture3.imagecreatefrompng//Open PNG image4.imagecreatefromwbmp//Open wbmp picture (less)5.getimagesize//Get picture size information6.imagecopymerge//Integrate multiple images (the main function of adding watermarks)7.imagejpeg//Save JPG Images8.imagegif//Save GIF
! ');
Note: If you have other table field names in the upload we need to take advantage of the post to accept it, otherwise you may not accept the value.
After you complete the above steps, you will be able to add a watermark to your uploaded images. Here's a little demo I wrote.Watermark Class
The code is as follows
Copy Code
/*** Add Watermark Class* Jones Taiwan Blog*/Class water{Private $imgPath; Picture pathPublic function __construct ($imgPath = "./")
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.